#ifndef		MDP_SOLVER_H
#define		MDP_SOLVER_H

#include "MatlabDrawer.h"
#include "types.h"

class MREAgent; 
class TFGenerator; 
class RFGeneralizer; 



namespace planning
{
class MDPSolver: public matlab::MatlabDrawer
{
public: 
	MDPSolver(MREAgent* a, TFGenerator* tf, RFGeneralizer* rf);

	virtual ~MDPSolver(){}

	virtual void operator ()()=0; 
	virtual Action getBestAction(Observation state)=0; 
	virtual void	solveModel(Observation currentState)=0; 
	virtual double getStateValue(const Observation o)=0; 
	virtual double getStateValueFast(const Observation o){return getStateValue(o); } 

	virtual void draw(); 
public: 
	MREAgent* agent; 

	TFGenerator* tfGens;		//reward function of the generative model
	RFGeneralizer* rfGens;	//transition function of the generative model 
	int action_number; 



	//used when multi-threading is enabled
	void stop(){running = false;}
	bool running; 

};


class SlaveableMDPSolver: public MDPSolver
{
public:
	SlaveableMDPSolver(MREAgent* a, TFGenerator* tf, RFGeneralizer* rf): MDPSolver(a,tf,rf){isVIRunning = false; NUMBER_OF_SLAVES = 0 ; }

	bool isVIRunning;				//this is a flag that denotes whether the current model solving is running or not (it's different from running flag in MDPSolver)
	int NUMBER_OF_SLAVES; 
};
}

#endif
